/**
 * 
 */
package net.entelijan.cobean.table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

class SortItem {

	private int index;

	private boolean descending;

	public SortItem(int index, boolean descending) {
		super();
		this.index = index;
		this.descending = descending;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public boolean isDescending() {
		return descending;
	}

	public void setDescending(boolean descending) {
		this.descending = descending;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		} else if (obj instanceof SortItem) {
			return this.index == ((SortItem) obj).getIndex();
		} else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return this.index;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}
}